//<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Category extends CI_Controller {

	function __construct(){
		log_message(ETS_INFO, '### C:/admin/Category->construct');
		parent::__construct();
		$this->load->library('mylang');
		$this->mylang->load('admin');
	}
	
	public function index()
	{
		log_message(ETS_INFO, '### C:/admin/Category->index()');
		//Test data
		$categoryList = array(
			array(
				'id' => '1',
				'level'=>'0',
				'order'=>'1',
				'name'=>'阅读语法',
				'status'=>'1'
			),
			array(
				'id' => '11',
				'level'=>'1',
				'order'=>'1',
				'name'=>'快速阅读理解训练',
				'status'=>'1'
			),
			array(
				'id' => '12',
				'level'=>'1',
				'order'=>'2',
				'name'=>'深度阅读理解训练',
				'status'=>'1'
				),
			array(
				'id' => '121',
				'level'=>'2',
				'order'=>'1',
				'name'=>'初级阅读',
				'status'=>'1',
			),
			array(
				'id' => '122',
				'level'=>'2',
				'order'=>'2',
				'name'=>'中级阅读',
				'status'=>'1'
			),
			array(
				'id' => '123',
				'level'=>'2',
				'order'=>'3',
				'name'=>'高级阅读',
				'status'=>'1'
			),
			array(
				'id' => '124',
				'level'=>'2',
				'order'=>'4',
				'name'=>'模拟测试',
				'status'=>'1'
			),
			array(
				'id' => '2',
				'level'=>'0',
				'order'=>'2',
				'name'=>'模拟测试',
				'status'=>'1'
			),
			array(
				'id' => '21',
				'level'=>'1',
				'order'=>'1',
				'name'=>'初级篇',
				'status'=>'1'
			),
			array(
				'id' => '22',
				'level'=>'1',
				'order'=>'2',
				'name'=>'中级篇',
				'status'=>'1'
			),
			array(
				'id' => '23',
				'level'=>'1',
				'order'=>'3',
				'name'=>'高级篇',
				'status'=>'1'
			),
			array(
				'id' => '3',
				'level'=>'0',
				'order'=>'3',
				'name'=>'视听说写',
				'status'=>'1'
			),
			array(
				'id' => '31',
				'level'=>'1',
				'order'=>'1',
				'name'=>'听力理解训练',
				'status'=>'1'
			),
			array(
				'id' => '32',
				'level'=>'1',
				'order'=>'2',
				'name'=>'听写训练',
				'status'=>'1'
			),
			array(
				'id' => '321',
				'level'=>'2',
				'order'=>'1',
				'name'=>'听写专项训练',
				'status'=>'1',
			),
			array(
				'id' => '322',
				'level'=>'2',
				'order'=>'2',
				'name'=>'听写模拟习题',
				'status'=>'1',
			)
		);
		$this->_convertDataToShow($categoryList);
		
		$this->load->vars('categoryList',$categoryList);
		log_message(ETS_INFO, '### goto V:/admin/category.php');
		$this->load->view('admin/category');
	}
	
	function _convertDataToShow(&$categoryList){
		log_message(ETS_INFO, '### C:/admin/Category->_convertDataToShow()');
		foreach ($categoryList as &$category){
			$category['status'] = $category['status'] == 1? '是': '否';
			$category_indention = '';
			for($i = 0, $len = $category['level']; $i < $len; $i++){
				$category_indention .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
			}
			$category['indention'] = $category_indention;
		}
	}
}